package main

import (
	"fmt"
	"log"
	"os"
)

func fmtPrint() {
	_, err := os.Open("no-file.txt")
	if err != nil {
		fmt.Println("use fmt.Println:", err)
	}
}

func logPrint() {
	_, err := os.Open("no-file.txt")
	if err != nil {
		log.Println("use log.Println :", err)
	}
}

func logSetOutput() {
	lf, _ := os.Create("./20_error-handling/01_log/log.txt")
	log.SetOutput(lf)
	_, err := os.Open("no-file.txt")
	if err != nil {
		log.Println("use log.SetOutput -> log.Println :", err)
		log.Fatalf("use log.SetOutput -> log.Println :", err)
	}
}

func panicPrint() {
	_, err := os.Open("no-file.txt")
	if err != nil {
		panic(err)
	}
}

func main() {
	//fmtPrint()
	//logPrint()
	//logSetOutput()
	panicPrint()
}
